package generation;

/**
 * @author Boshi Li
 */
public class CodeTableElement {
	//index of code table ( regarding Lab )
	private int index = -1;
	private String operator = "";
	private String address1 = "";
	private String address2 = "";
	private String result = "";
	public CodeTableElement( int index, String operator, String address1, String address2, String result) {
		this.index = index;
		this.setOperator(operator);
		this.setAddress1(address1);
		this.address2 = address2;
		this.setResult(result);
	}
	public String getOperator() {
		return operator;
	}
	public void setOperator(String operator) {
		this.operator = operator;
	}
	public int getIndex() {
		return index;
	}
	public void setIndex(int index) {
		this.index = index;
	}
	public String getResult() {
		return result;
	}
	public void setResult(String result) {
		this.result = result;
	}
	public String getAddress1() {
		return address1;
	}
	public void setAddress1(String address1) {
		this.address1 = address1;
	}
	
	@Override
	public String toString(){
		return index + ":" + operator + "," + address1 + "," + address2 + "," + result;
	}
	
	public String getQuad(){
		String addr1 = "-";
		String addr2 = "-";
		String res = "-";
		
		if( !address1.equals("") ){
			addr1 = address1;
		}
		if( !address2.equals("") ){
			addr2 = address2;
		}
		if( !result.equals("") ){
			res = result;
		}
		return  "(" + operator + "," + addr1 + "," + addr2 + "," + res + ")";
	}

}
